﻿package bdz.projects.lavender.doi.ui
{
	import flash.events.*;
	import flash.utils.*;
	
	import gs.*;
	import gs.easing.*;
	
	import org.papervision3d.cameras.*;
	import org.papervision3d.events.InteractiveScene3DEvent;
	import org.papervision3d.materials.*;
	import org.papervision3d.objects.primitives.Plane;
	/**
	 * ...
	 * @author ...
	 */
	public class DOINavigationView extends DOIPlane 
	{
		
		
		private var _padding:Number = 2;
		protected var _items:Array;
		protected var _definition:Object;
		
		
		protected var _allow:Boolean = true;
		protected var _lastEvent:String;
		
		function DOINavigationView(itms:Array, def:Object = null) {
			super("navigationView", null, true);
			_items = itms;
		}
		private function renderPaperMenu():void {
			for each(var obj:Object in _items) {
				obj.baseRenderer = _renderer;
				obj.labelRenderer = "NavItemLabel";
			}
			pmenu = new PaperMenu(_items, "grid");
			pmenu.baseTransparency = .7;
			_frontContainer.addChild(pmenu);
		}
		override protected function renderPlane(delay:Number = 0):void {
			super.renderPlane(delay);
			renderPaperMenu();
			var pls:Array = pmenu.planes;
			
			var bmat:MovieMaterial = new MovieMaterial(_backPlane, false, false, false);
			bmat.smooth = true;
			
			var pl:Plane = new Plane(bmat, _backPlane.width, _backPlane.height, 3, 3);
			_backContainer.addChild(pl);
			
			createBackLabelPlane("Home");
			activateControls();
		}
		override protected function roll3DActions(evt:InteractiveScene3DEvent):void {
			if((evt.target as Plane).userData){
				var udata:Object = (evt.target as Plane).userData.data;
				
				var pmenuitem:PaperMenuItem  = udata.movie.pmenu;
				var rolled:Boolean = evt.type == InteractiveScene3DEvent.OBJECT_OVER;
				if (rolled) {
					pmenuitem.createInBetween(new NavItemRoll(), 1);
					TweenMax.to(pmenuitem, .6, { z: -60, ease:Strong.easeInOut} );	
				}else {
					pmenuitem.removeInBetween();
					TweenMax.to(pmenuitem, .6, {z:0, ease:Strong.easeInOut} );
				}			
			}else {
				
			}
			super.roll3DActions(evt);
		}
		
	}
	
}